/**
 *
 */
package com.wedroid.r2d2.support;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * @author lute
 *
 */
public class BaseResponse {

    @JSONField(name = "Ret")
    private int ret;

    @JSONField(name = "ErrMsg")
    private String errMsg;

    /**
     * Default constructor
     */
    public BaseResponse() {
        // default -1 to be false
        ret = -1;
    }

    /**
     * @return
     */
    public boolean isSuccess() {
        return ret == 0;
    }

    /**
     * @return the ret
     */
    public int getRet() {
        return ret;
    }

    /**
     * @return the errMsg
     */
    public String getErrMsg() {
        if (StringUtils.isBlank(errMsg)) {
            return "Get ret [" + ret + "] indicating some error";
        }
        return errMsg;
    }

    /**
     * @param ret the ret to set
     */
    public void setRet(int ret) {
        this.ret = ret;
    }

    /**
     * @param errMsg the errMsg to set
     */
    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

}
